<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head th:include="base/head::head"/>
<!--业务表单按钮信息-->
<body class="easyui-layout">
<div th:replace="base/load::load"/>
<div id="west-tool">
    <a href="#" class="icon-refresh" onclick="onRefreshDataList()"></a>
</div>
<div id="table-tool">
    <a id="btn-add" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true" onclick="onOpenLocalAddDialog()">新增</a>
    <!--<a id="btn-edit" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-edit',plain:true" onclick="onOpenEditDialog()">修改</a>-->
    <a id="btn-remove" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-remove',plain:true" onclick="onRemove()">删除</a>
    <!--<a id="btn-default" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-create',plain:true" onclick="onDefault()">生成默认</a>-->
    <a id="btn-refresh" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-refresh',plain:true" onclick="onRefresh()">刷新</a>
</div>
<div data-options="region:'west',split:true,title:'业务表单',tools:'#west-tool'" style="width:200px;">
    <div id="list" class="easyui-datalist" data-options="url:'../form/list?formStatus=1',valueField:'formName',textField:'formDisplay',method:'get',fit:true,border:false,animate:true,onClickRow:onListItemClick"></div>
</div>

<div data-options="region:'center',title:'权限列表'" style="overflow: hidden;">
    <table id="table" class="easyui-datagrid" data-options="fit:true,singleSelect:false,rownumbers:true,toolbar:'#table-tool'">
        <thead>
        <tr>
            <th data-options="field:'id',checkbox:true"></th>
            <th data-options="field:'formName',width:100">业务标识</th>
            <th data-options="field:'formOperation',width:100">权限标识</th>
        </tr>
        </thead>
    </table>
</div>

<!--弹出框-->
<div id="dialog" class="easyui-dialog uq_dialog" data-options="title:'操作',closed:true,buttons:'#dialog-tool'">
    <form id="form" method="post">
        <input id="id" name="id" type="hidden"/>
        <table>
            <tr>
                <td>业务标识:</td>
                <td>
                    <input id="formName" name="formName" class="easyui-textbox" style="width: 200px"/>
                </td>
                <td>权限:</td>
                <td>
                    <div id="formOperation" name="formOperation" class="easyui-combobox" style="width: 200px" data-options="data:Common.permissons,valueField:'value',textField:'label',panelHeight:'auto',required:true"/>
                </td>
            </tr>
        </table>
    </form>
</div>
<div id="dialog-tool">
    <a id="dialog-save" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-ok'" onclick="onSave()">保存</a>
    <a id="dialog-close" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-close'" onclick="javascript:$('#dialog').dialog('close')">关闭</a>
</div>
<script type="text/javascript" th:src="@{/utils/System.js}"></script>
<script type="text/javascript">

    // 刷新datalist
    function onRefreshDataList() {
        $("#list").datalist("reload");
        // 取消所用选中，并清空表格
        $("#table").datagrid("unselectAll");
        $("#table").datagrid("loadData", []);
    }

    function onListItemClick(index, node) {
        loadData(node.formName)
    }

    function onOpenLocalAddDialog() {
        var formVO = $("#list").datalist("getSelected");
        if (formVO == null) {
            AlertUtil.error("请选择业务表单后，在操作！");
            return;
        }
        onOpenAddDialog();
        $("#formName").textbox("setValue", formVO.formName);
    }

    function loadData(formName) {
        if (formName == null || formName == "") {
            return;
        }
        $("#table").datagrid({
            "url": "find?fn=" + formName,
            "method": "get"
        });
    }


</script>
</body>
</html>